package org.zcl.feign.fallback;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.zcl.entity.User;
import org.zcl.feign.ProducerClient;

/**
 * @Package org.zcl.feign.fallback
 * @PROJECT_NAME: hystrix-demo
 * @DESCRIPTION:
 * @USER: zhuchenglin
 * @DATE: 2022/2/10 16:48
 */
@Component
public class ProducerClientFallbackFactory implements FallbackFactory<ProducerClient> {
    @Override
    public ProducerClient create(Throwable throwable) {
        return new ProducerClient() {
            @Override
            public String hello(String name, Integer mills) {
                return "producer service not available! " + throwable;
            }

            @Override
            public String add(User user) {
                return "producer service not available! " + throwable;
            }
        };
    }
}
